/* Copyright (C) 2011 clueless <clueless.mmopeon@gmail.com>
 *
 * This file is part of MMO Peon.
 *
 * MMO Peon is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MMO Peon is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MMO Peon.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __MMOPEON_WAYPOINTS_H
#define __MMOPEON_WAYPOINTS_H

#include <pugixml.hpp>
#include <string>
#include <vector>
#include "../commontypes.h"
/**
 * The Waypoints class is a container object for waypoint information,
 * it keeps track of the current active waypoint and assists in iterating
 * through the waypoints
 *
 * Waypoints()  Takes a file path in the form of std::string, the file is supposed to be an XML file
 *              with waypoint information
 *
 * IsEmpty()    returns true when no waypoints (coordinates) are in the container
 * IsInit()     returns false when there is no 'current' waypoint assigned
 *              You can assign this waypoint by calling Nearest()
 * Nearest()    takes a RomCoords object and sets the nearest waypoint to whichever
 *              waypoint is closest to the location of that object
 * Next()       returns the next waypoint and also sets the current waypoint to that waypoint
 * Previous()   returns the previous waypoint and also sets the current waypoint to that waypoint
 * Current()    returns the current waypoint
 */
class Waypoints
{
    public:
    Waypoints(const std::string &filename);

    bool IsEmpty() const;
    bool IsInit() const;
    const RomCoords& Current() const;
    const RomCoords& Next();
    const RomCoords& Previous();
    const RomCoords& Nearest(const RomCoords& source);

    private:
    void LoadWaypoints(const std::string &filename);
    //void SaveWaypoints();

    bool init;
    std::vector<RomCoords> data;
    std::vector<RomCoords>::iterator current;
};

#endif
